package homework2.miningPopularSong.reducer;

import java.util.Comparator;

/* This interface imposes a total ordering on the objects of each class that implements it */

public class Song implements Comparable<Song> {
	
	private String name;
	private Integer numberPlayed;

	public Song(String name, Integer numberPlayed) {
		this.name = name;
		this.numberPlayed = numberPlayed;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getNumberPlayed() {
		return numberPlayed;
	}

	public void setNumberPlayed(Integer numberPlayed) {
		this.numberPlayed = numberPlayed;
	}

	@Override
	public int compareTo(Song o) {
		return this.getNumberPlayed() - o.getNumberPlayed();
	}

	public static Comparator<Song> SongComparator = new Comparator<Song>() {
		public int compare(Song s1, Song s2) {
			return s1.compareTo(s2);
		}
	};
		
	public static Comparator<Song> ReverseSongComparator = new Comparator<Song>() {
		public int compare(Song s1, Song s2) {
			return -s1.compareTo(s2);
		}
	};

}
